Skip to content

feat(polymarket): prediction-market section — venue, AI analysis, suggestions & trading#161

Merged
FurkanEdizkan merged 5 commits into
testfrom
feat/polymarket-venue
Jun 11, 2026
Merged

feat(polymarket): prediction-market section — venue, AI analysis, suggestions & trading#161
FurkanEdizkan merged 5 commits into
testfrom
feat/polymarket-venue

Conversation

@FurkanEdizkan

Copy link
Copy Markdown
Owner

Summary

Adds a Polymarket prediction-market section to the platform, mirroring the Binance side with venue access, automated trading, trade suggestions and alerts — but tuned for prediction markets (AI bet/news analysis instead of high-frequency trading).

  • Venue: restores PolymarketVenue with per-strategy venue routing
  • Markets: market discovery, watchlist and AI bet analysis
  • Strategy: Prediction AI strategy for Polymarket outcome tokens
  • Web: Polymarket section — market browser, watchlist, AI analyses, settings
  • Docs: setup guide, abstraction notes, changelog

60 files changed, +4965 / −75.

🤖 Generated with Claude Code

claude added 5 commits June 11, 2026 11:42
Re-adds Polymarket as a venue (prediction markets, CLOB API) following the
re-adding checklist in docs/venues/abstraction.md, and makes venue routing
per-strategy so Binance and Polymarket strategies run side by side:

- Restore engine/venues/polymarket.py + tests from the pre-reduction tree,
  and add PolymarketOrderClient — a py-clob-client wrapper that signs and
  submits live CLOB market orders (shares are converted to a USDC amount
  for market BUYs; responses normalised for the venue).
- Register the venue (no sandbox; credential fields private_key, api_key,
  api_secret, passphrase, wallet_address) and wire build_venue: public
  market data with no creds, signing client with the full set.
- BaseStrategy/StrategyInstance/AISignal gain a `venue`; VenueRouter and
  ExecutorRouter accept an explicit venue override; the engine resolves
  market data and executors per strategy venue. Testnet mode falls back to
  Sim for venues without a sandbox.
- Widen symbol columns to 80 chars (Polymarket token ids are ~77 digits) —
  migration 0022.
- tests/__init__.py: py-clob-client deps ship a stray top-level `tests`
  package; mark our tests directory a regular package so imports resolve.

https://claude.ai/code/session_01RGKRo1Xjvhv9UMsQMpNvNj
Adds the engine/polymarket module — the prediction-market side of the
platform, deliberately slow-cadence (markets move on events and news, not
ticks):

- Discovery: refresh_markets pulls the top-volume active markets from the
  public Gamma API into a local prediction_market catalogue (upsert by
  condition id); list/search/watch APIs under /api/polymarket power the
  market browser. Migration 0023.
- AI bet analysis: analyze_market packs a market's question, prices, time
  to resolution and news headlines matched to the question's keywords
  (new news.service.search), asks the configured writer LLM for a strict
  -JSON probability estimate, and stores the edge (estimate minus market
  price) as a market_analysis row. Usage recorded as purpose=polymarket
  under the daily AI spend cap.
- Screening: run_screening_cycle analyses the watchlist plus the top-N
  markets every N hours; an analysis clearing the operator's edge and
  confidence bars becomes a pending AISignal (Telegram + dashboard) that
  executes through the existing risk-gated confirmation path.
- Resolution sync: watched/held markets are re-checked hourly; on
  resolution the position settles at 1/0 USDC directly into the
  sub-ledger (redemption, not an order) and the operator is alerted.
- Settings: polymarket_{refresh,research}_hours, edge threshold, min
  confidence, screen top-N and stake — readable/updatable via
  /api/settings (PUT /api/settings/polymarket).

https://claude.ai/code/session_01RGKRo1Xjvhv9UMsQMpNvNj
Adds PredictionAIStrategy — automated trading on AI-found edge. It
subclasses AIStrategy so the engine's existing AI machinery (per-strategy
provider/model resolution, daily spend cap, usage recording and the
notify/auto action mode) applies unchanged:

- Each tick it reads the latest stored bet analysis for its token's
  market, re-running the AI at a configurable cadence when stale; enters
  when the token's edge clears edge_threshold with min_confidence, exits
  when the edge is gone. NO tokens mirror the stored YES edge.
- Closed/resolved markets are never traded — the resolution sync settles
  held tokens at 1/0.
- Registered as a pickable type; StrategyType gains a `venue` pin
  (prediction_ai → polymarket) enforced by build_strategy and surfaced
  via /api/strategies/types, and kind=="AI" checks become
  isinstance(AIStrategy) so the subclass inherits model config, seeding
  and the read model.

https://claude.ai/code/session_01RGKRo1Xjvhv9UMsQMpNvNj
…yses

- New Polymarket page (route + sidebar entry): browse the discovered
  markets most-traded first with search and an All/Watchlist scope, pin
  markets to the AI's watchlist, and open a detail panel showing the
  latest AI bet analysis — estimated probability vs market price, edge,
  confidence and reasoning, with the recent-analysis trail. Admins can
  refresh the catalogue and run a one-off "Analyze now".
- Strategies page: venue selector on the create form (locked when a type
  is pinned, e.g. Prediction AI → Polymarket); Polymarket token-id
  symbols stay case-sensitive and render truncated with a venue badge.
- Settings page: Polymarket card for the discovery/screening cadence,
  edge threshold, min confidence, screen top-N and suggested stake. The
  Polymarket credential form comes from the generic per-venue renderer.
- lib/api/polymarket.ts client; OpenAPI schema + generated types
  regenerated.

https://claude.ai/code/session_01RGKRo1Xjvhv9UMsQMpNvNj
- polymarket-setup.md: drop the "not yet selectable" warning; document the
  section's features (discovery, AI bet analysis, suggestions, Prediction
  AI, resolution settlement), the five stored credential fields and the
  Sim-fallback behaviour in Testnet mode.
- abstraction.md: document per-strategy venue routing.
- README / docs index / api-features / research status: Binance-only
  framing becomes Binance + Polymarket; roadmap Phase 8 marked in
  progress.
- CHANGELOG: Unreleased "Added" entry for the whole section.

https://claude.ai/code/session_01RGKRo1Xjvhv9UMsQMpNvNj
@FurkanEdizkan
FurkanEdizkan merged commit 57685a3 into test Jun 11, 2026
4 checks passed
@FurkanEdizkan
FurkanEdizkan deleted the feat/polymarket-venue branch June 11, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants